<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <p>使用typeof运算符，可以获知变量的数据类型。</p>
    <p>typeof运算符，返回变量类型的字符表现方式。</p>
    <h2>typeof的可能值</h2>
    <ul>
        <li>string</li>
        <li>number</li>
        <li>boolean</li>
        <li>object</li>
        <li>undefined</li>
        <li>symbol</li>
        <li>function</li>
    </ul>
</head>
<body>
    <script>
        let a = "123";
        let r = typeof a;
        console.log(r); // string

        a = 123;
        r = typeof a;
        console.log(r); // number

        a = true;
        r = typeof a;
        console.log(r); // boolean

        a = null;
        r = typeof a;
        console.log(r); // object

        a = undefined;
        r = typeof a;
        console.log(r); // undefined

        a = Symbol(1);
        r = typeof a;
        console.log(r); // symbol

        // 容易错的两个值：
        a = function() {};
        r = typeof a;
        console.log(r); // function

        // 数组字面量表示方式，数组typeof的结果是object
        a = [];
        r = typeof a;
        console.log(r); // object

        

    </script>
</body>
</html>